package com.vekis.fixplore.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import com.sencha.gxt.ui.client.util.Margins;
import com.sencha.gxt.ui.client.widget.ContentPanel;
import com.sencha.gxt.ui.client.widget.Html;
import com.sencha.gxt.ui.client.widget.Viewport;
import com.sencha.gxt.ui.client.widget.container.border.BorderLayoutContainer;
import com.sencha.gxt.ui.client.widget.container.border.BorderLayoutContainer.BorderLayoutData;
import com.sencha.gxt.ui.client.widget.container.common.MarginData;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class FIXplore implements EntryPoint
{
	public Widget asWidget()
	{
		BorderLayoutContainer con = new BorderLayoutContainer();
		con.setPixelSize(800, 400);

		ContentPanel north = new ContentPanel();
		ContentPanel west = new ContentPanel();
		ContentPanel center = new ContentPanel();
		ContentPanel south = new ContentPanel();
		
		west.setHeaderVisible(false);
		south.setHeaderVisible(false);
		
		north.add(new Html("<h1 style=\"margin:15px;\">FIXplore</h1>"));
		west.add(new Html("<div style=\"margin:15px;\">Perhaps a menu here</div>"));
		center.add(new Html("<div style=\"margin:15px;\">And this will be the main trading interface"));
		
		// South split 
		BorderLayoutContainer southLogs = new BorderLayoutContainer();
		ContentPanel southLeft = new ContentPanel();
		ContentPanel southRight = new ContentPanel();
		BorderLayoutData southLeftData = new BorderLayoutData();
		southLeftData.setSize(500);
		southLeft.setHeadingText("Client message log here");
		southRight.setHeadingText("Server message log here");
		
		southLogs.setWestWidget(southLeft, southLeftData);
		southLogs.setCenterWidget(southRight);
		
		south.add(southLogs);
		
		
		center.setHeadingText("BorderLayout Example");
		BorderLayoutData northData = new BorderLayoutData(100);
		northData.setMargins(new Margins(0, 0, 5, 0));

		BorderLayoutData westData = new BorderLayoutData(150);
		westData.setMargins(new Margins(0, 5, 0, 0));
		westData.setSize(300);
		
		MarginData centerData = new MarginData();

		BorderLayoutData southData = new BorderLayoutData(200);
		southData.setMargins(new Margins(5, 0, 0, 0));

		con.setNorthWidget(north, northData);
		con.setWestWidget(west, westData);
		con.setCenterWidget(center, centerData);
		con.setSouthWidget(south, southData);
		return con;
	}

	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad()
	{
	    Widget con = asWidget();
	    
	    Viewport viewport = new Viewport();
	    viewport.add(con);
	    
		RootPanel.get().add(viewport);
	}
}